<%@page import="com.sdry.model.llm.Team"%>
<%@page import="com.sdry.model.llm.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>工位：离心</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/assets/ztree/css/zTreeStyle/zTreeStyle.css">
	
	<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
	<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
	<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
	<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.all.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.excheck.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/ztree/js/jquery.ztree.exedit.js"></script>
    <style type="text/css">
    	.font1 {
    		font-family:微软雅黑;
    		font-size:40px;
    		line-height: 110px;
    		color: #ffffff;
    		font-weight:bold;
    	}
    	.font2 {
    		font-family:微软雅黑;
    		font-size:38px;
    		line-height: 80px;
    		color: #ffffff
    	}
    	.font3 {
    		font-family:微软雅黑;
    		font-size:38px;
    		line-height: 80px;
    	}
    	.font4 {
    		font-family: 微软雅黑; 
    		font-size: 38px;; 
    		line-height: 40px
    	}
    	/* 设置表头 */
		#table1 tr .headTd {
			background-color: #4472C4;
			color: #ffffff
		}
    	/* 设置表头 */
		tr .titleTd {
			/* background-color: #BDD7EE; */
			color: #4472c4;
			border: 1px solid black;
		}
		.oddrowcolor{
			background-color:#d4e3e5;
		}
		.evenrowcolor{
			background-color:#c3dde0;
    	}
    	
    </style>
	<style>
		#code{
			font-size:26px;
			/* width:400px; */
			display:inline-block;
			/* height: 100px; */
		}
		#tdd tr td{
			border: 1px #654b4b80 solid;
			font-size: 18px;
			min-width: 100px;
			
			line-height: 25px;
			align:center;
		}
		#tdd tr td img{
			height: 101px;
			min-width: 101px;
			vertical-align: bottom;
		}
		#tdd a{ 
			border:1px solid white;
			display:inline-block;
			/* line-height:0px */
			min-width: 101px;
		    color: #8a074c;
		    min-height: 101px; 
		    
		    line-height:80px; 
			display: block;
		}
	</style>
</head>

<%
		Team team = (Team)request.getSession().getAttribute("team");
		User people = (User) request.getSession().getAttribute("currentUser");
	    String name = null;
	    if(people != null){
	      name = people.getUserName();
	    }
	    String teamName = null;
	    if(team != null){
	    	teamName = team.getTname();
	    }
	%>

<script type="text/javascript">

	//离心机状态定时刷新
	setInterval(function() {lxjStare()},1000*60*0.5);
	//时间
	setInterval(function() {mytime()},1000);
	var format = "";
	//时分秒
	function mytime(){
		var d=new Date(format);
		var day=d.getDate();
		d.setSeconds(d.getSeconds()+1);
		format = d;
		var month=d.getMonth() + 1;
		var year=d.getFullYear();
		var weekday=new Array(7);
		weekday[0]="星期日";
		weekday[1]="星期一";
		weekday[2]="星期二";
		weekday[3]="星期三";
		weekday[4]="星期四";
		weekday[5]="星期五";
		weekday[6]="星期六";
		var b = d.toLocaleTimeString();
		document.getElementById('myTime').innerHTML = year + "年" + month + "月" + day+"日"+"&nbsp;<br>"+weekday[d.getDay()]+b;
	    //document.getElementById("time1").innerHTML = b;
	}
	//年月日+星期
	function load(){
		format = '${format}';
		var d=new Date(format);
		var day=d.getDate();
		var month=d.getMonth() + 1;
		var year=d.getFullYear();
		var weekday=new Array(7);
		weekday[0]="星期日";
		weekday[1]="星期一";
		weekday[2]="星期二";
		weekday[3]="星期三";
		weekday[4]="星期四";
		weekday[5]="星期五";
		weekday[6]="星期六";
		var b = d.toLocaleTimeString();
		document.getElementById('myTime').innerHTML = year + "年" + month + "月" + day+"日"+"&nbsp;<br>"+weekday[d.getDay()]+b;
	    //document.getElementById("time1").innerHTML = b;
	    
	}
	 
	 function add0(m){
	    	return m<10?'0'+m:m 
	 }
    
	//初始化
	$(function() {
		//年月日+星期  排产单
		load();
		selectDaysheduTime()
	    /* var product = $("#product").html();
		if(product == "" || product == undefined || product == null) {
			return;
		}else {
			//根据产品查询
	    	selectNum();
		} */
		//根据查询
    	selectNum();
	})
	//查询排产单日期
    function selectDaysheduTime() {
    	$.ajax({
    		type:'post',
    		url:'/solid/selectDaysheduTime.do',
    		success:function(data){
    			$("#planTime").html(data);
    		}
    	});
    }
	function selectNum() {
    	//var position = "离心";
    	//var product = $("#product").val();
    	
    	//计划量
    	/* $.ajax({
	    	type:'post',
	    	async:false, 
	    	url:'${pageContext.request.contextPath }/shedu/selectByDate.do',
	    	data: {"product":product,"position":position},
	    	success:function(data){
	    		$("#planNum").html(data);
	    	}
	    }); */
    	
    	//日产量
	    /* $.ajax({
	    	type:'post',
	    	async:false, 
	    	url:'${pageContext.request.contextPath }/centrifugal/selectNumByDateAndProduct.do',
	    	data: {"product":product},
	    	success:function(data){
	    		$("#realityNum").html(data);
	    	}
	    }) */
	    
	    //当前离心数量
	    $.ajax({
	    	type:'post',
	    	async:false, 
	    	url:'${pageContext.request.contextPath }/centrifugal/selectLxNum.do',
	    	success:function(data){
	    		$("#realityNum").html(data);
	    	}
	    })
	    
    	//年产量
	    $.ajax({
	    	type:'post',
	    	async:false, 
	    	url:'${pageContext.request.contextPath }/centrifugal/selectNumByYear.do',
	    	success:function(data){
	    		$("#yearNum").html(data);
	    	}
	    })
	}

</script>
<body>
   <span id="planTime" style="display:none"></span>
   <table id="table1" style="width: 100%; text-align: center;" border="1px solid #000">
   		<tr>
   			<td rowspan="2" colspan="2" width="30%">
   				<img alt="" src="${pageContext.request.contextPath }/img/logo.png" width="60%">
   			</td>
   			<td rowspan="2" width="30%" class="headTd">
   				<p class="font1">离心工位</p>
   			</td>
   			<td colspan="2" width="20%" class="headTd">
   				<p class="font2">操作人</p>
   			</td>
   			<td rowspan="2" colspan="2" width="20%" class="headTd">
   				<a id="myTime"  class="font2"></a>
   				<a id="time1" class="font2"></a>
   			</td>
   		</tr>
   		<tr>
   			<td colspan="2"  class="font2 headTd" id="people"><%=name%></td>
   		</tr>
   		
   		<tr>
   			<td colspan="2" class="font3 titleTd">当前离心数量</td>
   			<td colspan="6"  class="font3 titleTd">离心机</td>
   		</tr>
   		<tr>
   			<td colspan="2" class="font3" id="realityNum">&nbsp;</td>
   			<td colspan="6" rowspan="5" class="font3" style="border: 0;">
   				<div id="code">
					<table id="tdd">
						<tr>
							<td style="background:url(${pageContext.request.contextPath }/img/1.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a1"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/2.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a2"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/3.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a3"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/4.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a4"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/5.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a5"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/6.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a6"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/7.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a7"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/8.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a8"></a></td>
						</tr>
						<tr>
							<td id="s1"></td>
							<td id="s2"></td>
							<td id="s3"></td>
							<td id="s4"></td>
							<td id="s5"></td>
							<td id="s6"></td>
							<td id="s7"></td>
							<td id="s8"></td>
						</tr>
						<tr>
							<td style="background:url(${pageContext.request.contextPath }/img/9.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a9"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/10.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a10"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/11.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a11"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/12.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a12"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/13.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a13"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/14.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a14"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/15.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a15"></a></td>
							<td style="background:url(${pageContext.request.contextPath }/img/16.png) no-repeat 0 0;background-size: 100% 100%;"><a id="a16"></a></td>
						</tr>
						<tr>
							<td id="s9"></td>
							<td id="s10"></td>
							<td id="s11"></td>
							<td id="s12"></td>
							<td id="s13"></td>
							<td id="s14"></td>
							<td id="s15"></td>
							<td id="s16"></td>
						</tr>
					</table>
					<br>
				</div>
			</td>
   		</tr>
   		<tr>
   			<td colspan="2" class="font3 titleTd">
   				当前年生产量
   			</td>
   		</tr> 
   		<tr>
   			<td colspan="2" class="font3" id="yearNum">&nbsp;</td>
   		</tr> 
   		<tr>
   			<td colspan="2" style="line-height: 185px;">&nbsp;</td>
   		</tr>
   		<tr>
   			<td class="font3" id="repair" style="background-color: #4472C4;font-family: 微软雅黑; color: #ffffff;border-width: 8px; border-color: #ffffff">设备报修</td>
   			<td class="font3" id="bad" style="background-color: #4472C4;font-family: 微软雅黑; color: #ffffff;border-width: 8px; border-color: #ffffff">配件报检</td>
   		</tr>
   		<tr>
   			<td class="font3" id="gongyika" style="background-color: #4472C4;font-family: 微软雅黑; color: #ffffff;border-width: 8px; border-color: #ffffff">工艺卡</td>
   			<td class="font3" id="zuoye" style="background-color: #4472C4;font-family: 微软雅黑; color: #ffffff;border-width: 8px; border-color: #ffffff">作业管理</td>
   		</tr>
   		<tr>
   			<td colspan="2" class="font3" id="back" style="background-color: #676767;font-family: 微软雅黑; color: #ffffff;border-width: 8px; border-color: #ffffff">注销</td>
   		</tr>
   </table>
   
   
<!-- ----------------------------点击按钮事件------------------------------ -->
	<!-- 离心机扫码弹框 -->
	<div id="lxjDivID" hidden="hidden">
		<form  id="lxjFormID">
			<label class="layui-form-label left-label">膜管1</label>
			<input class="layui-input" id="g1" name="g1" style="width:300px; margin-top:15px"><br>
			<label class="layui-form-label left-label">膜管2</label>
			<input class="layui-input" id="g2" name="g2" style="width:300px; margin-top:15px"><br>
			<!-- 离心机编号 -->
			<input type="hidden" id="ccode" name="ccode">
			<button type="button" class="layui-btn layui-btn-blue" id="saveCentrifugal" style="margin-left:160px; margin-bottom: 20px">绑定离心机</button>
			&emsp;&emsp;&emsp;&emsp;
			<!-- <button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button> -->
			<button type="button" class="layui-btn layui-btn-primary" id="resetCentrifugal" style="margin-bottom: 20px">重置</button>
		</form>
	</div>


	<!-- 配件列表 -->
	<div id="peiDivID" hidden="hidden">
   
	   	<div class="demoTable" style="padding:10px 0 0 15px">
			<label class="layui-form-label">配件名称</label>
		    <div class="layui-inline">
		    	<input class="layui-input" name="searchName" id="searchName" placeholder="" style="display: inline; width: 80%">
		    </div>
		    <button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload" id="serch"><i class="layui-icon layui-icon-search">  搜索</i></button>
		</div>
		<table class="layui-hide" id="peiList" lay-filter="peiList"></table>
	</div>
	
	<!-- 配件报检 -->
	
	 <div id="ngDivID" hidden="hidden">
	<form class="layui-form layui-card-body" id="formID" action="${pageContext.request.contextPath}/ng/insert.do">
	  	<input type="hidden" name="istation" value="离心">
	  	<div class="layui-form-item">
			<label class="layui-form-label">条码</label>
			<input class="layui-input" lay-verify="type" type="text" name="icode" id="icode" style="width:200px;">
		</div>
   		<div class="layui-form-item">
   			<div class="layui-inline">
				<label class="layui-form-label">配件名称</label>
				 <div class="layui-input-inline">
					<input class="layui-input" type="text" name="iname" id="iname" lay-verify="iname" style="width:200px;" onclick="pei()">
				</div>
			</div>
			<div class="layui-inline">
				<font style="color:red; font-size: 24px;">*</font>
		    </div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">配件规格</label>
			<div class="layui-input-block">
 				<input class="layui-input"  lay-verify="type" type="text" name="istandard" id="istandard" style="width:200px;">
 			</div>
		</div>
		<div class="layui-form-item"><label class="layui-form-label">配件批次号</label><input class="layui-input" lay-verify="type" type="text" name="ibatch" id="ibatch" style="width:200px;"></div>
		<div class="layui-form-item"><label class="layui-form-label">配件数量</label><input class="layui-input" lay-verify="type" type="text" name="inum" id="inum" style="width:200px;"></div>
  		<div class="layui-form-item">
  			<label class="layui-form-label">异常描述</label>
  			<div class="layui-input-inline" style="width:200px;">
                <input type="text" name="idescription" id="idescription" class="layui-input" style="position:absolute;z-index:2;width:80%;" lay-verify="idescription" onkeyup="search()" autocomplete="off">
		      	<select type="text" id="hc_select"  lay-filter="hc_select" autocomplete="off" class="layui-select" lay-search>
		      	</select>
  			</div>
  			<div class="layui-inline">
				<font style="color:red; font-size: 24px;">*</font>
		    </div>
  		</div>
  		
  		 <div class="layui-form-item">
		    <label class="layui-form-label">是否推送</label>
		    <div class="layui-input-block">
		      <input type="checkbox" name="remark01" lay-skin="switch" lay-text="ON|OFF">
		    </div>
		  </div>
  		
  		<button class="layui-btn layui-btn-blue" lay-submit lay-filter="subform" id="save" style="margin-left:120px; margin-bottom: 20px">提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" id="cz" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button>
	</form>
</div>
	<script type="text/html" id="rowToolbar">
		<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="back">带回</a>
	</script>
	<script type="text/javascript">
		var index;
		function pei() {
			$("#searchName").val("");
			$("#serch").click();
			index = layer.open({
				type: 1 					//Page层类型
				,area: ['750px', '600px'] 	//宽  高
				,title: '选择配件'
				,shade: 0.6 				//遮罩透明度
				,maxmin: true 				//允许全屏最小化
				,anim: 1 					//0-6的动画形式，-1不开启
				,content: $("#peiDivID")
				,end: function(){
					$("#peiDivID").hide();
				} 
			});
		}
	</script>
<script>
toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上


//input id头
var inp = "g";
//input 开始数字
var inpK = 1;
//input 结束数字
var inpJ = 2;
//input 开始id
var id = inp+inpK;
function keyDown(e){  
    //IE内核浏览器  
     if (navigator.appName == 'Microsoft Internet Explorer'){  
           var keycode = event.keyCode;  
           var realkey = String.fromCharCode(event.keyCode);  
     }else {//非IE内核浏览器  
           var keycode = e.which;  
           var realkey = String.fromCharCode(e.which);  
     }  
   // console.log('按键码:' + keycode +  '字符: ' + realkey);  

   //监听Ctrl键  
   if(keycode==13){ 
	   if($("#icode").val() != null && $("#icode").val() != "" && $("#icode").val() != undefined) {
		   var icode =  $("#icode").val();
			$("#icode").val(icode+",");
		   return;
	   }
	   var idz=$("input:focus").attr("id");   
	   if(idz != null && idz != "" && idz != undefined){
		   if(id != idz){
		    	toastr.warning("请按顺序扫码！");
		    	$("#"+idz).val("");
		    	$("#"+id).select(); 
		    }else{
			    id = tz(id);
		        $("#"+id).focus();  
		        $("#"+id).select();
		    }
	   }else{
	    	$("#"+id).focus();  
	        $("#"+id).select();
	    }
   }  
   $("#"+id).change(function(){
       console.log($(this).val());  
       $("#"+id).select();  
   })  
   
}  
//按键事件
document.onkeydown=keyDown; 

function tz(id){ 
	var a=document.getElementById("lxjDivID")
	//判断a的display是否是none
	if (a.style.display != 'none'){
		//层已经打开
		id = tz1(id)
	} 
	return id
}
function tz1(id){ 
	var h = $("#"+id).val()
	if(h == "" || h == null){
		toastr.warning("不能为空！");
	}else if(h.length != 16 || h.substring(1,3) != "PS"){
		toastr.warning("请扫码正确的膜管编号！");
	}else{
		if(tj(id)){
			var data = id.split(inp);
			var input = data[1];
			if(parseInt(input) < parseInt(inpJ)){
				id = inp+(parseInt(data[1])+1);
			}else{
				//最后一个
				id = inp+inpK;
			}
		}
	}
	return id
}

//根据膜管查组装信息
function selectAssembleByAtubeOrMbcode(id){ 
    var listM=new Array()
	var h = $("#"+id).val()
	$.ajax({
        type:'post',
        url:'${pageContext.request.contextPath }/assemble/selectassembleByExample.do',
        data: "atube"+"=" + h,
        dataType: 'JSON',
        async:false, 
        success:function(data){
           	for (var i = 0; i < data.length; i++) {
           		listM.push(data[i].mbcode)
           	}
        }

    })
    return listM;
}

//扫码操作 true继续进行 false重新扫码
function tj(id){ 
	var flg = true;
	if (id != (inp+inpJ)) {
		
		var listM = selectAssembleByAtubeOrMbcode(id);
		if(listM.length == 0){
			toastr.warning("该膜管没有经过组装！");
			flg = false;
		}else{
			
			//膜丝捆是否有重复 true否false是
			if(!findCentrifugalByCtube(id,"ctube")){
				toastr.warning("已经有重复的！");
				flg = false;
			}
		}
	}else{
		var listM = selectAssembleByAtubeOrMbcode(id);
		if(listM.length == 0){
			toastr.warning("该膜管没有经过组装！");
			flg = false;
		}else{
			
			if(!findCentrifugalByCtube(id,"ctube") || !jspFor(id)){
				toastr.warning("已经有重复的！");
				flg = false;
			}else{
				//膜丝捆是否提交成功 true否false是
				if(centrifugalSave(id)){
					toastr.success("提交成功！");
					setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
	                    //window.location.reload();
	                    //$("#reset").click();
						lxjStare(); 
						layer.closeAll();
	                },1000);
				}else{
					toastr.warning("提交失败！");
					flg = false;
				} 
			}
		}
	}
	return flg;
}

//膜丝根是否有重复 true否false是
function findCentrifugalByCtube(id,name){ 
	var flg = true;
	var h = $("#"+id).val()
	$.ajax({
        type:'post',
        url:'${pageContext.request.contextPath }/centrifugal/selectcentrifugalByExample.do',
        data: name+"=" + h,
        dataType: 'JSON',
        async:false, 
        success:function(data){
            if(data.length == 0){
            	flg = true;
            }else{
                flg = false;
            }
        }

    })
    return flg;
}

//膜丝捆当前码是否和之前的码重复  true不 false重复
function jspFor(id){
	var flg = true;
	var h = $("#"+id).val()
	var data = id.split(inp)
	var input = data[1];
	for (var i = 0; i < parseInt(input); i++) {
		var hh = $("#"+inp+i).val();
		if(h == hh){
			flg = false;
			break;
		}
 	}
    return flg;
}

//膜丝捆是否提交成功 true否false是
function centrifugalSave(id){ 
	var plan = $("#planTime").html();;
	var flg = true;
	var h = $("#ccode").val();
	var listC=new Array();
	for (var i = 1; i <= parseInt(inpJ); i++) {
		var ii = $("#"+inp+i).val()
		if(ii != "" && ii != null){
			listC.push($("#"+inp+i).val());
		}
	}
	$.ajax({
        type:'post',
        url:'${pageContext.request.contextPath }/centrifugal/plInsertcentrifugal.do',
        data:{"ccode":h,"listC":listC,"cplan":plan},
        dataType: 'JSON',
        async:false, 
        //传递数组使用
        contentType: "application/x-www-form-urlencoded",
        success:function(data){
            if(data != 0){
            	flg = true;
            	selectNum();
            	//减库存
            	//chuxbku(listC);
            }else{
                flg = false;
            }
        }

    })
    return flg;
}

//出线边库
function chuxbku(listC){ 
	//膜丝，产品，膜丝类型,组件尺寸对应关系数组
	var productArr = 
		[
			 ["01","PSH2-0960-T-01","热法","0960"]
			 ,["02","PSH2-0980-T-02","热法","0980"]
			 ,["03","PSH1-1060-B-03","湿法","1060"]
			 ,["04","PSH1-1080-C-04","湿法","1080"]
		];
		var planNumebr = $('#planTime').text();
		var teamName = '<%=teamName%>';
	for (var i = 0; i < listC.length; i++) {
		var m = listC[i];
		var product = "";
		//根据膜丝（01....），产品，膜丝类型、组件尺寸对应关系数组给产品，膜丝类型赋值
		for (var j = 0; j < productArr.length; j++) {
			var arr = productArr[j];
			if(m.substring(3,7) == arr[3]){
				product=arr[1];
			}
		};
		//减库存
		$.ajax({
			type:'post'
			,url:'${pageContext.request.contextPath }/lineSideLibrary/lineSideLibraryOut.do?pnum='+product+'&&quantity=1&&productionOrder='+planNumebr+'&&team='+teamName+'&&type=1&&positionName=离心'
			,dataType:'json'
			,success:function(res){
				
			}
		}) 
	}
}
//离心机状态刷新
function lxjStare(){ 
	var ccodeArr = new Array()
	var ztArr = new Array()
	var iArr = new Array()
	//绑定
	var bdcArr = new Array()
	var bdiArr = new Array()
	var bdztArr = new Array()
	$.ajax({
        type:'post',
        url:'${pageContext.request.contextPath }/others/deviceByMution.do',
        data:{"deviceName":"离心机"},
        dataType: 'JSON',
        async:false, 
        //传递数组使用
        success:function(data){
        	if(data.length == 16){
        		for (var i = 0; i < data.length; i++) {
    		    	var dd = document.getElementById("a"+(i+1));
    				//给a标签赋值
    				dd.innerText =data[i].deviceNo;
    				var oDiv = document.getElementById("s"+(i+1)); 
    				if(data[i].remark05 == "" || data[i].remark05 == null || data[i].remark05 == "空闲"){
    					$("#s"+(i+1)).html("空闲");
    					oDiv.style.background = "#00FE67";
    				}else{
    					if(data[i].remark05 == "绑定"){
	    					$("#s"+(i+1)).html(data[i].remark05);
	    					oDiv.style.background = "#4FBFFF";
	    					bdcArr.push(data[i].deviceNo);
	    					bdiArr.push(i);
	    					bdztArr.push(data[i].remark05);
    					}else{
    						var zt = data[i].remark05;
    						ccodeArr.push(data[i].deviceNo);
    						ztArr.push(zt);
    						iArr.push(i);
	    					$("#s"+(i+1)).html(zt);
	    					if(data[i].remark05 == "1遍胶"){
		    					oDiv.style.background = "#E7FF75";
	    					}else if(data[i].remark05 == "2遍胶"){
		    					oDiv.style.background = "#FFD800";
	    					}else if(data[i].remark05 == "3遍胶"){
		    					oDiv.style.background = "#FF9600";
	    					}
    					}
    				}
    		    }
        	}else{
    			toastr.warning("该离心机个数不是16！");
        	}
        }
    })
    for(var i = 0; i < iArr.length; i++) {
    	//计划量
    	$.ajax({
	    	type:'post',
	    	async:false, 
	        url:'${pageContext.request.contextPath }/Kanban/selectTimeByCcode.do',
	    	data: {"ccode":ccodeArr[i]},
	    	dataType: 'JSON',
	    	success:function(data){
	    		var html = ztArr[i];
	    		var ctubes = data.ctubes;
	    		for(var j = 0; j < ctubes.length; j++) {
	    			html += "<br>"+ctubes[j]
	    		}
    			html += "<br>"+data.time+"  "+data.wenDu+"℃"
	    		$("#s"+(iArr[i]+1)).html(html);	
    		}
	    }); 
	}
	for(var i = 0; i < bdiArr.length; i++) {
    	//计划量
    	$.ajax({
	    	type:'post',
	    	async:false, 
	        url:'${pageContext.request.contextPath }/Kanban/selectCtubeByCcode.do',
	    	data: {"ccode":bdcArr[i]},
	    	dataType: 'JSON',
	    	success:function(data){
	    		var html = bdztArr[i];
	    		var ctubes = data.ctubes;
	    		for(var j = 0; j < ctubes.length; j++) {
	    			html += "<br>"+ctubes[j]
	    		}
	    		//alert(bdiArr[i]+1+"-------"+html)
	    		$("#s"+(bdiArr[i]+1)).html(html);
	    	}
	    }); 
	}
}

//点击"+"和"-"效果
$(function(){
    var index;
    /* $("#add").click(function(){ */
    $("body").on("click", "#add", function() {
        //console.log($(this).parents('tr').get(0));
        var rowId = $(this).parents('tr').attr("id");
        //alert(rowId);
        var tbody = document.getElementById("tbody");
        index = tbody.rows.length + 1;
        var tab = document.getElementById('myTable');
        //指定行号
        var rowNumNext = document.getElementById(rowId).rowIndex + 1;
        //在指定行下插入一行
        var tr = tab.insertRow(rowNumNext);
        //给tr设置动态Id和样式
        tr.id = "tr" + index;
        tr.style = "text-align: center";
        //在行下插入列内容
        var cell0 = tr.insertCell(0);
        var cell1 = tr.insertCell(1);
        var cell2 = tr.insertCell(2);
        var cell3 = tr.insertCell(3);
        var cell4 = tr.insertCell(4);

        cell0.innerHTML = '<td><input class="layui-input" id="changeDeviceName" name="changeDeviceName" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell1.innerHTML = '<td><input class="layui-input" id="deviceVersion" name="deviceVersion" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell2.innerHTML = '<td><input class="layui-input" id="deviceCount" name="deviceCount" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell3.innerHTML = '<td><input class="layui-input" id="deviceUnit" name="deviceUnit" type="text" style="width:122px; margin-left: 27px; margin-bottom: 15px"></td>';
        cell4.innerHTML = '<td><i class="layui-icon layui-icon-add-1" id="add" style="font-size: 15px; color: #1E9FFF;"></i><br><i class="layui-icon layui-icon-close" id="recover" style="font-size: 15px; color: #1E9FFF; font-weight: bold;"></i></td>';
    });

    $("body").on("click", "#recover", function() {
        var rowId = $(this).parents('tr').attr("id");
        $("#"+rowId).remove();
    })
});

layui.use(['table','layer','upload','form','laydate'], function(){
	var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
	var table = layui.table;
    var layer = layui.layer;
    var laydate = layui.laydate;
    var form = layui.form; 
    form.render();
    lxjStare();
    
    
    form.on('select(hc_select)', function (data) {   //选择移交单位 赋值给input框
        $("#idescription").val(data.value);
        $("#hc_select").next().find("dl").css({ "display": "none" });
        form.render();
    });

    window.search = function () {
        var value = $("#idescription").val();
        $("#hc_select").val(value);
        form.render();
        $("#hc_select").next().find("dl").css({ "display": "block" });
        var dl = $("#hc_select").next().find("dl").children();
        var j = -1;
        for (var i = 0; i < dl.length; i++) {
            if (dl[i].innerHTML.indexOf(value) <= -1) {
                dl[i].style.display = "none";
                j++;
            }
            if (j == dl.length-1) {
                $("#hc_select").next().find("dl").css({ "display": "none" });
            }
        }
        
    }
    
    //选择文本框
  	$("#"+id).select(); 
    
    var $ = layui.jquery, active = {
			reload:function () {
				var searchName = $("#searchName").val();
				table.reload('contenttable2',{
					method:'get',
					where:{"paname":searchName},
					page:{
						curr:1  //重新从第一页开始
					}
				});
			}
		  }
  
  $('.layui-btn').on('click', function(){
      var type = $(this).data('type');
      active[type] ? active[type].call(this) : '';
  });
    
    $.ajax({
        type: "post",
        url: "${pageContext.request.contextPath }/json/options.json",
        dataType: 'JSON',
        success: function (data) {
              //设置下拉列表中的值的属性
       		 $("#hc_select").append('<option value="">请选择</option>'); 
              for ( var i = 0; i < data.length; i++) {
            	  //增加下拉列表。
            	  $("#hc_select").append("<option>"+data[i].name+"</option>");
            	  form.render('select');
              }
        }
  	});

  table.render({
	    elem: '#peiList'
	    ,url:'${pageContext.request.contextPath }/partMana/listPagePart.do'
	    ,title: '配件列表'
	    ,id :'contenttable2'
	    ,limits:[10,20,30]
	    ,cols: [[
			      {field:'paname', title:'配件名称',width:200},
			      {field:'panum', title:'配件编号' ,width:150},
			      {field:'pamodel', title:'配件规格',width:200},
			      {field:'paremark1', title:'计量单位',width:100},
			      //{field:'paremark2', title:'包装规格',width:100},
			      {fixed:'right', title:'操作', toolbar: '#rowToolbar', width:80}
			    ]],
	    page: true,
  });
		  
  table.on('tool(peiList)', function(obj){
		var data = obj.data;
		console.log(obj)
		if(obj.event === 'back'){
			
		    $("#iname").val(obj.data.paname); 
		    $("#istandard").val(obj.data.pamodel); 
		    var id = obj.data.paid;
		    $.ajax({
		    	type:'post',
		    	data: {"id":id},
		    	url:'/solid/selectPcByPaid.do',
		    	success:function(data){
		    		$("#ibatch").val(data); 
		    	}
		    });
		    if($("#iname").val() != null ) {
		    	layer.close(index); 
		    }
		    
		}
  });
    
    //设备报修
  $('#repair').click(function(){   
	  layer.open({
	         type: 1 					//Page层类型
	         ,area: ['50%', '83%'] 	//宽  高
	         ,title: '设备报修'
	         ,shade: 0.6 				//遮罩透明度
	         ,maxmin: true 				//允许全屏最小化
	         ,anim: 1 					//0-6的动画形式，-1不开启
	         //,content: $("#addFormID")
	         ,content: '<form class="layui-form" id="addFormID">'+
	         '<table>'+
	         '<tr>'+
	             '<td><label class="layui-form-label left-label" style="margin-top: 20px;width:150px;" >设备编号</label></td>'+
	             '<td>'+
	                 '<div>'+
	                     '<div style="width: 200px; margin-left: 0px; float: left; margin-top: 20px">'+
	                         '<select class="layui-select" id="deviceNo" name="deviceNo" lay-filter="displayInfo" lay-verify="deviceNo">'+
	                             '<option value="">请选择</option>'+
	                         '</select>'+
	                     '</div>'+
	                     '<div style="margin-top: 29px; float: left">'+
	                         '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
	                     '</div>'+
	                 '</div>'+
	             '</td>'+ 					
	             '<td><label class="layui-form-label left-label" style="margin-top: 20px;width:150px;">故障设备名称</label></td>'+
	             '<td><input type="text" id="deviceName" name="deviceName" lay-verify="deviceName" class="layui-input" style="width:200px; margin-top: 20px; display: inline;">' +
	                 '<div class="layui-inline" style="margin-top: 4px;">'+
	                     '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
	                 '</div>'+
	             '</td>'+
	         '</tr>'+
	         '<tr style="height:10px"></tr>'+
	         '<tr>'+
	             '<td><label class="layui-form-label left-label" style="width:150px;">报修部门/车间</label></td>'+
	             '<td>'+
	                 '<div>'+
	                     '<div style="width: 200px; margin-left: 0px; float: left">'+
	                         '<select class="layui-select" id="repairDept" name="repairDept" lay-verify="repairDept">'+
	                             '<option value="">请选择</option>'+
	                         '</select>'+
	                     '</div>'+
	                     '<div style="margin-top: 9px; float: left">'+
	                         '<font style="color:red; font-size: 24px; margin-left: 4px">*</font>'+
	                     '</div>'+
	                 '</div>'+
	             '</td>'+
	             '<td><label class="layui-form-label left-label" style="width:150px;">报修人</label></td>'+
	             '<td><input type="text" name="repairMan" id="repairMan" value="<%= name%>" class="layui-input" style="width:200px"></td>'+
	         '</tr>'+
	         '<tr style="height:10px"></tr>'+
	         '<tr>'+
	             '<td><label class="layui-form-label left-label"  style="width:150px;">报修时间</label></td>'+
	             '<td><input type="text" name="repairTime" id="repairTime"  class="layui-input" style="width:200px"></td>'+
	             '<td></td>'+
	             '<td></td>'+
	         '</tr>'+
	         '<tr style="height:10px"></tr>'+
	         '<tr>'+
	             '<td><label class="layui-form-label left-label" style="width:150px;">故障现象描述</label></td>'+
	             '<td colspan="3"><textarea class="layui-textarea" id="errorDescribe" name="errorDescribe" style="width: 540px; height: 150px;"></textarea></td>'+
	         '</tr>'+
	         '<tr style="height:10px"></tr>'+
	         '<tr>'+
	             '<td colspan="2">' +
	                 '<label class="layui-form-label" style="width:150px;">审批人</label>' +
	                 '<input readonly class="layui-input" lay-verify="approvalPeople" placeholder="请选择审批人" name="approvalPeople" id="approvalPeople" type="text" style="width:100px; display:inline; margin-left: 19px">' +
	                 '<i style="font-size:15px;" id="refresh" class="layui-icon layui-icon-refresh"></i>' +
	                 '<ul id="treeConfig" class="ztree" style="margin-left: 120px;"></ul>'+
	             '</td>'+
	             '<td colspan="2">' +
	                 '<label class="layui-form-label" style="width:150px;">抄送人</label>' +
	                 '<input readonly class="layui-input" lay-verify="ccPeople" placeholder="请选择三个抄送人" name ="ccPeople" id="ccPeople" type="text" style="width:200px; display:inline">' +
	                 '<i style="font-size: 15px;" id="dCopyMenRefresh" class="layui-icon layui-icon-refresh"></i>'+
	                 '<ul id="dCopyMenConfig" class="ztree" style="margin-left: 100px;"></ul>'+
	             '</td>'+
	         '</tr>'+
	         '<tr style="height:20px"></tr>'+
	         '<tr align="center">'+
	             '<td colspan="2"><button class="layui-btn layui-btn-blue" id="subBtn" lay-submit lay-filter="addForm" style="margin-left:160px; margin-bottom: 20px">提交</button>&emsp;&emsp;'+
	             '<td colspan="2"><button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button>'+
	         '<tr>'+
	     '</table>'+
	 '</form>'
	     
				,success: function(){
				 
				 var people = $("#people").text();
					$("#repairMan").val(people);
				 
				 //报修时间
				 laydate.render({
				     elem: '#repairTime'
				 });
					//维修起始时间
				 laydate.render({
				     elem: '#fixStartTime'
				 });
				 //维修结束时间
				 laydate.render({
				     elem: '#fixEndTime'
				 });
				 //验收日期
				 laydate.render({
				     elem: '#acceptTime'
				 });
					//下拉查找所有设备
				 $.ajax({
				          type: 'POST',
				          url: '${pageContext.request.contextPath}/device/queryAllDeviceList.do',
				          dataType: 'json',
				          async: false,
				          success: function (data){
				              for (var i = 0; i < data.length; i++) {
				                  $("#deviceNo").append("<option value='"+ data[i].deviceNo +"'>"+ data[i].deviceNo +"</option>");
				              }
				          }
				      });
					//下拉框查找所有部门
					$.ajax({
				        type: 'POST',
				        url: '${pageContext.request.contextPath}/device/queryAllDeptList.do',
				        dataType: 'json',
				        async: false,
				        success: function (data){
				            for (var i = 0; i < data.length; i++) {
				                $("#repairDept").append("<option value='"+ data[i].name +"'>"+ data[i].name +"</option>");
				            }
				        }
				    });
					
					
					 $("#refresh").click(function(){
				            $("#approvalPeople").val("");
				        })
				        $("#dCopyMenRefresh").click(function(){
				            $("#ccPeople").val("");
				        })
				
				        var setting = {
				            isSimpleData : true,             //数据是否采用简单 Array 格式，默认false
				            treeNodeKey : "id",              //在isSimpleData格式下，当前节点id属性
				            treeNodeParentKey : "pId",       //在isSimpleData格式下，当前节点的父节点id属性
				            showLine : true,                 //是否显示节点间的连线
				            checkable : true,                //每个节点上是否显示 CheckBox
				            data: {
				                simpleData: {
				                    enable: true,
				                    idKey: "id",
				                    pIdKey: "pId",
				                    rootPid: "0"
				                }
				            },
				            callback: {
				                onDblClick: onDblClick,
				            }
				        };
				
				        var dCopyMenSetting = {
				            isSimpleData : true,              //数据是否采用简单 Array 格式，默认false
				            treeNodeKey : "id",               //在isSimpleData格式下，当前节点id属性
				            treeNodeParentKey : "pId",        //在isSimpleData格式下，当前节点的父节点id属性
				            showLine : false,                 //是否显示节点间的连线
				            data: {
				                simpleData: {
				                    enable: true,
				                    idKey: "id",
				                    pIdKey: "pId",
				                    rootPid: "0"
				                }
				            },
				            callback: {
				                onDblClick: dCopyMenOnDblClick,
				            }
				        };
				
				        function onDblClick(e,treeId,treeNode) {
				
				            selectedNode = treeNode;
				            var name = treeNode.name;
				            var id = treeNode.id;
				            var type = treeNode.type;
				            if(type!="-1"){
				                var dApprover1 = $("#approvalPeople").val();
				                var dApprovers = dApprover1.split(",");
				                for(var i=0;i<dApprovers.length;i++){
				                    if(name==dApprovers[i]){
				                        toastrStyle();
				                        toastr.warning("选择了重复的审批人！")
				                        name = "";
				                    }
				                }
				                var dApprover2;
				                if(dApprover1 == "" && name != ""){
				                    dApprover2 = $("#approvalPeople").val((dApprover1+','+name).substring(1));
				                }else if(name != ""){
				                    dApprover2 = $("#approvalPeople").val(dApprover1+','+name);
				                }
				                var dApprover3 =  $("#approvalPeople").val();
				                var dApprovers3 = dApprover3.split(",");
				                var dApprovers3Length = dApprovers3.length;
				                if(dApprovers3Length>1){
				                    toastr.warning("最多选择1个审批人");
				                    $("#approvalPeople").val(dApprover1);
				                }
				            }else{
				                toastrStyle();
				                toastr.warning("请选择审批人！")
				            }
				        }
				
				        function dCopyMenOnDblClick(e,treeId,treeNode) {
				            dCopyMenSelectedNode = treeNode;
				            var name = treeNode.name;
				            var id = treeNode.id;
				            var type = treeNode.type;
				
				            var dCopyMen = $("#ccPeople").val();
				            var dCopyMen = dCopyMen.split(",");
				            for(var i=0;i<dCopyMen.length;i++){
				                if(name==dCopyMen[i]){
				                    toastrStyle();
				                    toastr.warning("选择了重复的抄送人！")
				                    name = "";
				                }
				            }
				            if(dCopyMen == "" && name != ""){
				                dCopyMen = $("#ccPeople").val((dCopyMen+','+name).substring(1));
				            }else if(name != ""){
				                dCopyMen = $("#ccPeople").val(dCopyMen+','+name);
				            }
				        }
				
				        $.ajax({
				            type:'get',
				            url:'${pageContext.request.contextPath }/disposeRejects/getZtreeJson.do',
				            dataType:'json',
				            success: function(data){
				                var	zNodes = data.rows;
				                $(document).ready(function() {
				                    $.fn.zTree.init($("#treeConfig"), setting, zNodes);
				                });
				            },
				            error: function(){
				                toastrStyle();
				                toastr.error("请求失败");
				            }
				        });
				
				        $.ajax({
				            type:'get',
				            url:'${pageContext.request.contextPath }/disposeRejects/getZtreeJson.do',
				            dataType:'json',
				            success: function(data){
				                var	dCopyMenzNodes = data.rows;
				                $(document).ready(function() {
				                    $.fn.zTree.init($("#dCopyMenConfig"), dCopyMenSetting, dCopyMenzNodes);
				                });
				            },
				            error: function(){
				                toastrStyle();
				                toastr.error("请求失败");
				            }
				        });
					
				 //初始化radio、select等元素
				 form.render();
				}
			});
		})

       //注销
 	 $('#back').click(function(){   
	  window.location.href="${pageContext.request.contextPath }/logout.do";
  	 });
     
      //配件报检
 	$('#bad').click(function(){   
	 layer.open({
	   type: 1 					//Page层类型
  		,area: ['500px', '650px'] 	//宽  高
  		,title: '配件报检'
  		,shade: 0.6 				//遮罩透明度
  		,maxmin: true 				//允许全屏最小化
  		,anim: 1 					//0-6的动画形式，-1不开启
  		,content: $("#ngDivID")
  		,end: function(){
  			$("#ngDivID").hide();
  		}
   		,success: function(layero, index){
   			$("#cz").click();
   			form.render();
   			
   			$("#icode").focus(); 
   			
        this.enterEsc = function(event){
          if(event.keyCode === 13){
            return false; //阻止系统默认回车事件
          }
        }; 
        $(document).on('keydown', this.enterEsc);	//监听键盘事件，关闭层
    }
   });
  })
  
	
  	$("#tdd a").on("click",function(){
		$("#tdd a").css("border","1px solid white");
		$(this).css("border","1px solid red");
		var aids = this.id.split("a");
		
		var sid = $("#s"+aids[1]).html();
		if(sid == "空闲" || sid == "" || sid == null){
			$('#lxjFormID')[0].reset();
			//获取a标签的id
			//alert(this.id)
			layer.open({
				type: 1 					//Page层类型
		  		,area: ['500px', '350px'] 	//宽  高
		  		,title: '离心机绑定'
		  		,shade: 0.1 				//遮罩透明度
		  		,maxmin: true 				//允许全屏最小化
		  		,anim: 1 					//0-6的动画形式，-1不开启
		  		,content: $("#lxjDivID")
		  		,end: function(){
		  			$("#lxjDivID").hide();
		  			addFig = true;
		  		}
			    ,success: function(layero, index){
			        this.enterEsc = function(event){
			          if(event.keyCode === 13){
			            //layer.close(index);
			            return false; //阻止系统默认回车事件
			          }
			        }; 
			        $(document).on('keydown', this.enterEsc);	//监听键盘事件，关闭层
			        id = inp+inpK;
					$("#"+id).select();
			    }
			});  
			var dd = document.getElementById(this.id);
			$("#ccode").val(dd.innerHTML)
			$("#"+id).select();
		}else{
			toastr.warning("该离心机不空闲，无法绑定膜管！");
		}
  	});
  	$('#resetCentrifugal').click(function(){ 
  		$("#"+inp+inpK).val("")
  		$("#"+inp+inpJ).val("")
  		id = inp+inpK;
		$("#"+id).select();
  	});
	
  	var addFig = true; 
  	$('#saveCentrifugal').click(function(){ 
		var ii = $("#"+inp+inpK).val()
		var iijs = $("#"+inp+inpJ).val()
		var iid = inp+inpK
		var listM = selectAssembleByAtubeOrMbcode(iid);
		if(id == inp+inpJ && iijs != "" && iijs != null){
			//最后一个不执行
		}else if(ii == "" || ii == null){
			toastr.warning("至少扫码一个！");
		}else if(ii.length != 16 || ii.substring(1,3) != "PS"){
			toastr.warning("请扫码正确的膜管编号！");
		}else if(listM.length == 0){
			toastr.warning("该膜管没有经过组装！");
		}else if(!findCentrifugalByCtube(iid,"ctube")){
			toastr.warning("已经有重复的！");
		}else{
	  		if (!addFig) {
				return;
			}
	  		addFig = false;
	  		//膜丝捆是否提交成功 true否false是
			if(centrifugalSave(id)){
				toastr.success("提交成功！");
				addFig = true;
				setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
                    //window.location.reload();
                    //$("#reset").click();
					lxjStare(); 
					layer.closeAll();
                },1000);
			}else{
				toastr.warning("提交失败！");
			} 
		}
  	});
  	
	//查找带回
    form.on('select(displayInfo)', function(data){
    	$.ajax({
            type: 'POST',
            url: '${pageContext.request.contextPath}/device/queryDeviceInfoByNo.do',
            data: {deviceNo:$('#deviceNo').val()},
            /* dataType: 'json', */
            /* async: false, */
            success: function (data){
            	var device = eval('(' +data+ ')');
            	$('#deviceName').val(device.deviceName);
            }
        });
    });
  	
    /**
     * 通用表单提交(AJAX方式)(新增)
     */
    form.on('submit(addForm)', function (data) {
    	$("#subBtn").attr("disabled",true);
    	$.ajax({
            url : '${pageContext.request.contextPath}/breakdown/addDeviceBreakdown.do',
            data: $("#addFormID").serialize(),
            cache : false,
            type : "post",
        }).done(
            function(res) {
                if (res > 0) {
                    toastrStyle();
                    toastr.success('报修成功！');
                    setTimeout(function(){
                    	layer.closeAll();
                    },1000);
                }
            }
        ).fail(
            function(res) {
                toastrStyle();
                toastr.error('报修失败！');
                setTimeout(function(){
                	layer.closeAll();
                },1000);
            }
        )
        return false;
    });
  	
    form.on('submit(subform)', function (data) {
  	  	  
    	$("#save").attr("disabled",true);
    	
    	  var datas=data.field;
     	  var action=data.form.action;
     	  $.ajax({
     		  url:action,
     		  data:datas,
     		  type:"POST",
     		  dataType:"json",
     		  success:function(result){
     			 if(result > 0) {
     				toastr.success("报检成功！");
     				$("#reset").click();
     				layer.closeAll();
     			 }else {
     				 toastr.warning("报检失败！");
     				 return false;
     			 }
     		  },
     	  });
     	  
     	  return false;
  	  });

  	/**
      * 新增表单校验
      */
     form.verify({
         //value：表单的值item：表单的DOM对象
         deviceName: function(value, item){
             if(value == ''){
                 return '设备名称不能为空';
             }
         },
         deviceNo: function(value, item){
             if(value == ''){
                 return '设备编号不能为空';
             }
         },
         repairDept: function(value, item){
             if(value == ''){
                 return '报修部门不能为空';
             }
         },
         iname: function(value, item){
             if(value == ''){
                 return '配件名称不能为空';
             }
         },
         idescription: function(value, item){
             if(value == ''){
                 return '异常描述不能为空';
             }
         },
     });
});
	//工艺卡
	$('#gongyika').click(function(){   
 	 	window.location.href="${pageContext.request.contextPath }/jumpPage/craftDetails.do";
	 });
	//作业管理
	$('#zuoye').click(function(){   
 	 	window.location.href="${pageContext.request.contextPath }/jumpPage/workManage.do?positionName=离心";
	 });
//提示框样式
function toastrStyle() {
    toastr.options = {
        "closeButton": false,
        "debug": false,
        "newestOnTop": false,
        "progressBar": false,
        "positionClass": "toast-top-center",
        "preventDuplicates": false,
        "onclick": null,
        "showDuration": "5000",
        "hideDuration": "1000",
        "timeOut&quot": "100000",
        "extendedTimeOut": "0",
        "showEasing": "swing",
        "hideEasing": "linear",
        "showMethod": "fadeIn",
        "hideMethod": "fadeOut"
    };
}
</script>
</body>
</html>